Trò chơi đua xe động vật trong UNITY Engine
114.896 lượt xem;
- InterpolationElastic.cs
- Interpolations /
- Bapk /
- Scripts /
- Assets /
- project /
1 using UnityEngine;
2 using System.Collections;
3
4 public class InterpolationElastic : InterpolationProcess {
5 protected float value, power;
6
7 public InterpolationElastic(float value, float power)
8 {
9 this.value = value;
10 this.power = power;
11 }
12
13 public override float apply(float a)
14 {
15 if (a <= 0.5f)
16 {
17 a *= 2;
18 return Mathf.Pow(value, power * (a - 1)) * Mathf.Sin(a * 20) * 1.0955f / 2;
19 }
20 a = 1 - a;
21 a *= 2;
22 return 1 - Mathf.Pow(value, power * (a - 1)) * Mathf.Sin(a * 20) * 1.0955f / 2;
23 }
24 }
2 using System.Collections;
3
4 public class InterpolationElastic : InterpolationProcess {
5 protected float value, power;
6
7 public InterpolationElastic(float value, float power)
8 {
9 this.value = value;
10 this.power = power;
11 }
12
13 public override float apply(float a)
14 {
15 if (a <= 0.5f)
16 {
17 a *= 2;
18 return Mathf.Pow(value, power * (a - 1)) * Mathf.Sin(a * 20) * 1.0955f / 2;
19 }
20 a = 1 - a;
21 a *= 2;
22 return 1 - Mathf.Pow(value, power * (a - 1)) * Mathf.Sin(a * 20) * 1.0955f / 2;
23 }
24 }